<?php

namespace Register\Controller;

use Think\Controller;

class BaseController extends Controller {

  var $userId, $userInfo,$shopConfig,$userMenu;
  var $menuSelectClass = 'active';
  var $notcheck = array('login','findPwd');

  public function __construct() {
    parent::__construct();
   /* if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') > 0 ) {
        header('location:'.U('Wap/Index/index'));
    }*/
    if($this->userId > 0){
      $this->getAdminMenu();
    }
    $this->loadConfig();
    $this->assign('m', MODULE_NAME);
    $this->assign('c', CONTROLLER_NAME);
    $this->assign('a', ACTION_NAME);
  }
  /**
   * 批量处理路由
   */
  public function batchProcess() {
    $id = I("id");
    if(empty($id)){
      $this->error('请选择需要操作的信息.');
    }
    $batchAction = I("batch");
    $actionName = reset(array_keys($batchAction));
    if(method_exists($this,$actionName)){
      call_user_func(array($this,$actionName));
    }
  }
  
  private function loadConfig(){
    $shopConfigArray = C('shopConfig');
    foreach ($shopConfigArray as $key => $item) {
      $this->shopConfig[$key] = $item['value'];
    }
    $this->assign("shopConfig",$this->shopConfig);
    $this->assign("title",$this->shopConfig['shopName'].'用户登录');
  }

}
